<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Title</title>
  <script src="__STATIC__/index/js/global/jquery-3.2.1.min.js"></script>
</head>
<body>
  <a href="javascript:;" onclick="get_data()">打印</a>
    <div style="">
        <div id="print-area">
            <table id="print">
            </table>
        </div>
    </div>
    <script>
        function get_data(){
            $.post("{:url('Test/test')}",
                {id:1},
                function(data){
                    $('#print').html(data.data);
                    print();
                }
            );
        }

        /**
         * 打印小票
         */
        function print() {
            if (!!window.ActiveXObject || "ActiveXObject" in window) {
                remove_ie_header_and_footer();
            }
            var newWindow = window.open("打印窗口", "_blank");
            var docStr = $("#print-area").html();
            newWindow.document.write(docStr);
            newWindow.document.close();
            newWindow.print();
            newWindow.close();
            //        $("#print-area").jqprint({
            //            debug: false,
            //            importCSS: true,
            //            printContainer: true,
            //            operaSupport: false
            //        });
        }
        /**
         * 取出打印的页眉页脚
         */
        function remove_ie_header_and_footer() {
            var hkey_root, hkey_path, hkey_key;
            hkey_path = "HKEY_CURRENT_USER\\Software\\Microsoft\\Internet Explorer\\PageSetup\\";
            try {
                var RegWsh = new ActiveXObject("WScript.Shell");
                RegWsh.RegWrite(hkey_path + "header", "");
                RegWsh.RegWrite(hkey_path + "footer", "");
            } catch (e) {}
        }
    </script>
</body>
</html>